<template>
  <n-card :bordered="false" class="rounded-16px shadow-sm pt-4 pb-4">
    <div ref="domRef" class="h-500px"></div>
  </n-card>
</template>

<script setup lang="ts">
import { ref, toRefs, watch, watchEffect } from 'vue';
import { type ECOption, useEcharts } from '@/hooks/common/echarts';

type Props = {
  xDate: [],
  sDate: []
}
const props = defineProps<Props>()
const { xDate, sDate } = toRefs(props)
function initOptions(): ECOption {
  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985'
        }
      }
    },
    title: {
      text: '登录次数'
    },
    legend: {
      data: ['七天内登录次数']
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    toolbox: {
      feature: {
        saveAsImage: {}
      }
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: xDate.value
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        color: '#e7bcf3',
        name: '七天内登录次数',
        type: 'line',
        smooth: true,
        stack: 'Total',
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0.25,
                color: '#e7bcf3'
              },
              {
                offset: 1,
                color: '#fff'
              }
            ]
          }
        },
        emphasis: {
          focus: 'series'
        },
        data: sDate.value
      }
    ]
  }
}
const { domRef, updateOptions } = useEcharts(initOptions);



</script>
